import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Solution {

    // 一维前缀和
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) {
            int n = in.nextInt();
            int q = in.nextInt();
            int[] arr = new int[n + 1];
            for(int i = 1; i <= n; i++) {
                arr[i] = in.nextInt();
            }
            // 创建 dp 数组
            long[] dp = new long[n + 1];
            for(int i = 1; i <= n; i++) {
                dp[i] = dp[i - 1] + arr[i];
            }
            while(q > 0) {
                int l = in.nextInt();
                int r = in.nextInt();
                System.out.println(dp[r] - dp[l - 1]);
                q--;
            }
        }
    }

    // 二维前缀和
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) {
            int n = in.nextInt();
            int m = in.nextInt();
            int q = in.nextInt();
            int[][] arr = new int[n + 1][m + 1];
            for(int i = 1; i <= n; i++) {
                for(int j = 1; j <= m; j++) {
                    arr[i][j] = in.nextInt();
                }
            }
            // 创建 dp
            long[][] dp = new long[n + 1][m + 1];
            for(int i = 1; i <= n; i++) {
                for(int j = 1; j <= m; j++) {
                    dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + arr[i][j];
                }
            }
            // 查找
            while(q > 0) {
                int x1 = in.nextInt();
                int y1 = in.nextInt();
                int x2 = in.nextInt();
                int y2 = in.nextInt();
                System.out.println(dp[x2][y2] - dp[x1 - 1][y2] - dp[x2][y1 - 1] + dp[x1 - 1][y1 - 1]);
                q--;
            }
        }
    }

    // 寻找数组的中心下标
    public int pivotIndex(int[] nums) {
        // 创建 dp 数组
        int len = nums.length;
        int[] dp = new int[len + 1];
        for(int i = 1; i <= len; i++) {
            dp[i] = dp[i - 1] + nums[i - 1];
        }
        int sum = dp[len];
        for (int i = 1; i <= len; i++) {
            if (dp[i - 1] == (sum - nums[i - 1] - dp[i - 1])) {
                return i - 1;
            }
        }
        return -1;
    }

    public int pivotIndex2(int[] nums) {
        // 创建 dp 数组
        int len = nums.length;
        // 左侧所有元素之和
        int[] pre = new int[len + 1];
        // 右侧所有元素之和
        int[] last = new int[len + 1];
        for(int i = 1; i < len; i++) {
            pre[i] = pre[i - 1] + nums[i - 1];
        }
        for(int i = len - 2; i >= 0; i--) {
            last[i] = last[i + 1] + nums[i + 1];
        }
        for (int i = 0; i < len; i++) {
            if (pre[i] == last[i]) {
                return i;
            }
        }
        return -1;
    }

    // 除自身以外数组的乘积
    public int[] productExceptSelf(int[] nums) {
        int len = nums.length;
        int[] pre = new int[len]; // i 前所有元素之积
        int[] last = new int[len]; // i 之后所有元素之积
        pre[0] = last[len - 1] = 1;
        for(int i = 1; i < len; i++) {
            pre[i] = pre[i - 1] * nums[i - 1];
        }
        for(int j = len - 2; j >= 0; j--) {
            last[j] = last[j + 1] * nums[j + 1];
        }
        int[] ret = new int[len];
        for(int i = 0; i < len; i++) {
            ret[i] = pre[i] * last[i];
        }
        return ret;
    }

    // 和为k的子数组
    public int subarraySum(int[] nums, int k) {
        Map<Integer, Integer> hash = new HashMap<>();
        hash.put(0, 1);
        int sum = 0;
        int len = nums.length;
        // int[] dp = new int[len]; // 以 i 位置为结尾的所有子数组
        int ret = 0;
        for (int i = 0; i < len; i++) {
            sum += nums[i];
            // dp[i] = hash.getOrDefault(sum - k, 0);
            hash.put(sum, hash.getOrDefault(sum, 0) + 1);
            ret += hash.getOrDefault(sum - k, 0);
            // System.out.println(dp[i] + " " + hash.getOrDefault(sum - k, 0));
        }
        return ret;
    }

    // 和可被 K 整除的子数组
    public int subarraysDivByK(int[] nums, int k) {
        int len = nums.length;
        Map<Integer, Integer> hash = new HashMap<>();
        hash.put(0 % k, 1);
        int sum = 0;
        int ret = 0;
        for(int i = 0; i < len; i++) {
            sum += nums[i];
            int r = (sum % k + k) % k;
            ret += hash.getOrDefault(r, 0);
            hash.put(r, hash.getOrDefault(r, 0) + 1);
        }
        return ret;
    }

    // 连续数组
    public int findMaxLength(int[] nums) {
        Map<Integer, Integer> hash = new HashMap<>(); // k:sum v:index
        int ret = 0;
        int sum = 0;
        hash.put(0, -1);
        for(int i = 0; i < nums.length; i++) {
            sum += (nums[i] == 1 ? 1 : -1);
            // System.out.println(sum);
            if(!hash.containsKey(sum)) {
                hash.put(sum, i);
            } else {
                ret = Math.max(ret, i - hash.get(sum));
            }
        }
        return ret;
    }

    // 矩阵区域和
    public int[][] matrixBlockSum(int[][] mat, int k) {
        // 先计算前缀和
        int m = mat.length;
        int n = mat[0].length;
        int[][] dp = new int[m + 1][n + 1];
        for(int i = 1; i <= m; i++) {
            for(int j = 1; j <= n; j++) {
                dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + mat[i - 1][j - 1];
                // System.out.print(dp[i][j] + " ");
            }
            // System.out.println();
        }
        int[][] answer = new int[m][n];
        for(int i = 0; i < m; i++) {
            for(int j = 0; j < n; j++) {
                int x1 = Math.max(0, i - k) + 1;
                int y1 = Math.max(0, j - k) + 1;
                int x2 = Math.min(m - 1, i + k) + 1;
                int y2 = Math.min(n - 1, j + k) + 1;
                answer[i][j] = dp[x2][y2] - dp[x2][y1 - 1] - dp[x1 - 1][y2] + dp[x1 - 1][y1 - 1];
            }
        }
        return answer;
    }
}
